﻿/***********************************************************************
 * <copyright file="HoverTextExtension.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@buca.vn
 * Website:
 * Create Date: Friday, November 15, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/
using System;
using System.Web.Mvc;

namespace EasyUIMvc.Tooltip
{
    public class HoverTextExtension : ExtensionBase
    {
        private readonly TooltipHoverTextSettings _settings;
        private MvcHtmlString _content;

        public HoverTextExtension(TooltipHoverTextSettings settings)
        {
            _settings = settings;
        }

        public HoverTextExtension Content(string content)
        {
            _content = MvcHtmlString.Create(content);
            return this;
        }

        public override string GetScripts()
        {
            throw new NotImplementedException();
        }

        public override MvcHtmlString GetHtml()
        {
            var tooltip = GetTopTag("div", "easyui-panel easyui-tooltip", _settings);
            tooltip.MergeAttribute("title", _settings.TooltipText);
            tooltip.MergeAttribute("style", _settings.Style);
            tooltip.MergeAttribute("position", _settings.TooltipPosition);
            tooltip.InnerHtml += _content;

            return MvcHtmlString.Create(tooltip.ToString());
        }
    }

    public class TooltipHoverTextSettings : TooltipSettings
    {
        public string Style { get; set; }
    }
}
